$(document).ready(function(){
	restoreAnimalMeScreen();
});

function restoreAnimalMeScreen(){
	loadSpecie();
	

//	
//	//This specifications is from newanimal.html
//	$('select#insert_status_animal').selectmenu({maxHeight: 150, style: "dropdown"});
//	
//	$('select#insert_age_animal').selectmenu({maxHeight: 150, style:"dropdown"});
//	
//	$('select#insert_race_animal').selectmenu({maxHeight: 150, style:"dropdown"});
//	
//	$('select#insert_specie_animal').selectmenu({maxHeight: 150, style:"dropdown"});
//	//end of this specifications
//	
//	//This specifications is from searchanimal.html
//	$('select#search_size_animal').selectmenu({maxHeight: 150, style: "dropdown"});
//	//end of this specifications
//	
	$( "#date-news" ).datepicker({
		showOn: "button",
		buttonImage: "images/layout/calendar.png",
		buttonImageOnly: true,
		changeMonth: true,
		changeYear: true
	});
	
	
	$("#search_animal").button();
	$("#search_animal").bind("click", function(){
	});
	
	
	
};

function loadSpecie(){
	$.get("/dotcao/ws/specie/list", function(result) {
		$('select#load_specie_animal').html("");
		$("<option />").val("oh").html("Selecione uma espécie").appendTo("#load_specie_animal");
		$.each(result, function(index, item) {
			$("<option />").val(item.code).html(item.nome).appendTo("#load_specie_animal");
		});
		
		$('select#load_specie_animal').selectmenu("destroy").selectmenu({maxHeight: 150, style: "dropdown"});
	}, "json");
	
}



function loadRace(){
	$.get("/dotcao/ws/race/list/"+$("select#load_specie_animal").val(), function(result) {
		$('#load_race_animal').html("");
		$.each(result, function(index, item) {
			$("<option />").val(item.code).html(item.nome).appendTo("select#load_race_animal");
		});
		if(result=="")
			{
				$("<option />").val("oh").html("Nenhuma raça cadastrada").appendTo("#load_race_animal");
			}
		
		$('select#insert_race_animal').selectmenu("destroy").selectmenu({maxHeight: 150, style: "dropdown"});
	}, "json");
	
}